package com.company.class1;

import javax.swing.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        double a=0;
        double b=0;
        String str1 = null;
        String str = null;
        int i =1;
        double sum = 0;
        try {
            str1 = JOptionPane.showInputDialog("输入" + i + "的值：", "0");
            a = Double.parseDouble(str1);
        }catch (Exception e){
            JOptionPane.showMessageDialog(null, "请正确输入");
            System.exit(0);
        }
        while (1==1) {

            str = JOptionPane.showInputDialog("输入运算符：","=");
            if (str.equals("=")){
                break;
            }
            i = i+1;

            try {
                str1 = JOptionPane.showInputDialog("输入" + i + "的值：", "0");
                b = Double.parseDouble(str1);
            }catch (Exception e){
                JOptionPane.showMessageDialog(null, "请正确输入");
                System.exit(0);
            }
            if (str.equals("+")){
                sum = a + b;
            }
            else if (str.equals("/")){
                sum = a / b;
            }
            else if (str.equals("*")){
                sum = a * b;
            }
            else if (str.equals("-")){
                sum = a - b;
            }
            else if (str.equals("%")){
                sum = a % b;
            }else {
                JOptionPane.showMessageDialog(null, "请正确输入运算符！");
                System.exit(0);
            }
            a = sum;

        }

        JOptionPane.showMessageDialog(null,sum);
    }
}
